﻿using System.Diagnostics.Contracts;
using System;

namespace YasharEl.Infrastructure.ObjectFactory
{
    [ContractClass(typeof(DependencyContainerContract))]
    public interface IDependencyContainer
    {
        IDependencyContainer CreateChildContainer(string containerName = null);

        IDependencyContainer FindChildContainer(string containerName);

        IDependencyRegistrationTraverser CreateContainerTraverser();
    }

    [ContractClassFor(typeof(IDependencyContainer))]
    internal abstract class DependencyContainerContract : IDependencyContainer
    {
        public IDependencyContainer CreateChildContainer(string containerName = null)
        {
            return default(IDependencyContainer);
        }

        public IDependencyContainer FindChildContainer(string containerName)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(containerName), "containerName could not be null or empty.");

            return default(IDependencyContainer);
        }

        public IDependencyRegistrationTraverser CreateContainerTraverser()
        {
            return default(IDependencyRegistrationTraverser);
        }
    }
}
